#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
void cheng(int a1[][100], int a2[][100], int a3[][100], int a, int b, int y)
{
    int i = 0;
    int j = 0;
    int k = 0;
    for (i = 0; i < a; i++)
    {
        for (j = 0; j < y; j++)
        {
            a3[i][j] = 0;
            for (k = 0; k < b; k++)
            {
                a3[i][j] += a1[i][k] * a2[k][j];
            }
        }
    }
    printf("%d %d\n", a, y);
    for (i = 0; i < a; i++)
    {
        for (j = 0; j < y; j++)
        {
            printf("%d ", a3[i][j]);
        }
        printf("\n");
    }
}
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    int i = 0;
    int j = 0;
    int arr1[100][100];
    for (i = 0; i < a; i++)
    {
        for (j = 0; j < b; j++)
        {
            scanf("%d", &arr1[i][j]);
        }
    }
    int x, y;
    scanf("%d %d", &x, &y);
    int arr2[100][100];
    for (i = 0; i < x; i++)
    {
        for (j = 0; j < y; j++)
        {
            scanf("%d", &arr2[i][j]);
        }
    }
    int arr3[100][100];
    if (b != x)
    {
        printf("Error: %d != %d", b, x);
        goto over;
    }
    cheng(arr1, arr2, arr3, a, b, y);
over:
    return 0;
}

